def skob():
    st = []
    a = input('Введите скобочную последовательность: ')
    for i in range(len(a)):
        if a[i] in '([{<':
            st.append(a[i])
        if not st == []:
            if a[i] in ')]}>':
                if (st[-1] == '(' and a[i] == ')') or (st[-1] == '[' and a[i] == ']') or (st[-1] == '{' and a[i] == '}') or (st[-1] == '<' and a[i] == '>'):
                    st.pop(-1)
        else:
            return 0
    if st == []:
        return 1
    else:
        return 0
print(bool(skob()))
